#include "data.h"
#include <memory.h>
void data::dataass(string source,char des[])
{
    memset(des,0,sizeof(des));
	if(source == "")
	{
		source = " ";
	}
	int len = source.length();
    strcpy_s(des,len+1,source.c_str());

}

void data::datasetvalue(int type,int x,string question,string ans1,string ans2,string ans3,string ans4,int answer)
{
    this->type  = type;
    this->x = x;
    this->dataass(question,this->question);
    this->dataass(ans1,this->answer1);
    this->dataass(ans2,this->answer2);
    this->dataass(ans3,this->answer3);
    this->dataass(ans4,this->answer4);
    this->answertrue = answer;

}
string data::datagetwhat(int what)
{
    char message[256];
    switch(what)
    {
    case 0:
        this->dataass(question,message);
        break;
    case 1:
        this->dataass(answer1,message);
        break;
    case 2:
        this->dataass(answer2,message);
        break;
    case 3:
        this->dataass(answer3,message);
        break;
    case 4:
        this->dataass(answer4,message);
        break;
    }
    string s="";
    for(unsigned int i=0 ; i<sizeof(message); i++)
    {
        if(message[i] == 0)
        {
            return s;
        }
        else
        {
            s += message[i];
        }
    }
    return  s;

}
int data::datagetansertrue()
{
    return this->answertrue;
}
int data::datagetx()
{

    return this->x;
}

int data::datagettype()
{

    return this->type;
}

data::data()
{
    this->type = -1;
    this->x = -1;
    memset(question,0,sizeof(question));
    memset(answer1,0,sizeof(answer1));
    memset(answer2,0,sizeof(answer2));
    memset(answer3,0,sizeof(answer3));
    memset(answer4,0,sizeof(answer4));
}

data::~data()
{
    this->type = -1;
    this->x = -1;
    memset(question,0,sizeof(question));
    memset(answer1,0,sizeof(answer1));
    memset(answer2,0,sizeof(answer2));
    memset(answer3,0,sizeof(answer3));
    memset(answer4,0,sizeof(answer4));
}
